﻿import React from 'react'
import { Select } from 'antd'
const Option = Select.Option

class SelectDom extends React.Component {
  constructor (props) {
    super(props)

    this.state = {}
  }

  render () {
    let {list, labelKey, valueKey, width, className, disabled} = this.props
    valueKey = valueKey || 'id'
    labelKey = labelKey || 'name'
    width = width || 100
    list = list || []
    global.LangMessage = global.LangMessage || {}
    let tip = global.LangMessage.text_select || '请选择'
    let optList = list.map((item, index) =>
      <Option value={item[valueKey] + ''} key={item[valueKey] + '' + index} title={item[labelKey]}>{item[labelKey] || ''}</Option>
    )
    return (
      <Select style={{ width: width }} className={className} disabled={disabled} placeholder={tip} {...this.props}>
        {optList}
      </Select>
    )
  }
}

export default SelectDom
